﻿using System;
using static System.Formats.Asn1.AsnWriter;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;
using Yitter.IdGenerator;

namespace Code.Test
{
    //public delegate void MyDelegate(string name, int score);

    internal class Program
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            ///张三
            Student zs = new Student();
            zs.Age = 10;

            Student ls = zs;

            //李四
            ls.Age = 20;

            //问  zs.age
            Console.WriteLine(zs.Age);

            int a = 10;
            int b = a;
            b = 20;
            //问a
            Console.WriteLine(a);

            Console.ReadLine();








            #region 这一部分是组织数据的，不用管            
            string[] dt1 = new string[] {
                "2022-07-27 18:01:19","2022-07-27 18:04:19","2022-07-27 18:06:19",
                "2022-07-28 05:03:13","2022-07-28 05:09:13","2022-07-28 05:12:13",
                "2022-07-28 05:15:13","2022-07-28 05:18:13"
            };

            var list = dt1.Select(m => {
                var time = DateTime.Now;
                if(Convert.ToDateTime(m).Date == new DateTime(2022, 7, 27))
                {
                    time = Convert.ToDateTime("2022/8/10 9:48:34");
                }
                else
                {
                    time = Convert.ToDateTime("2022/7/27 18:06:22");
                }

                var obj = new Tmodel
                {
                    HintTime = Convert.ToDateTime(m),
                    ApprTime = time
                };
                return obj;
            }).ToList();
            #endregion

            //这里是判断最近的提示时间，并且只保留一次，其他的会赋值为null
            //把这里换到你的代码上就行
            List<DateTime> temp = new List<DateTime>();
            list.ForEach(m => {
                if (temp.Any(a => m.ApprTime == a))
                {
                    m.ApprTime = null;
                }
                else
                {
                    temp.Add(Convert.ToDateTime(m.ApprTime));
                }
            });

            //下面这段是通过分组来完成第几天的显示
            //根据HintTime这个字段，同一天的显示1天，按昨晚的测试数据，一共是2天
            var group = list.GroupBy(m => m.HintTime.Date);

            var index = 0;
            foreach (var item in group)
            {
                index++;
                foreach (var data in item)
                {
                    data.Days = $"第{index}天";
                }
            }
            
            Console.ReadLine();
        }
    }


    public class Student
    {
        public int Age { get; set; }
    }


    public class Tmodel
    {
        public string Days { get; set; }
        public DateTime HintTime { get; set; }
        public DateTime? ApprTime { get; set; }
    }
}
